package cn.wtg.kotlindemo.testRxjava3

import cn.wtg.kotlinlib.net.base.RetrofitManager
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers

/**
 * author: wtg
 * time: 2022/12/17
 * desc:
 */
class TestRxjavaModel private constructor() {
    private var testRxjavaService = RetrofitManager.getInstance()?.createService(TestRxjavaService::class.java)
    companion object {
            val singleton: TestRxjavaModel by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
                TestRxjavaModel()
            }
        }

    /**
     * 获取数据
     */
    fun getWeatherData(observer: BaseObserver<List<BrandBannerBean>>){
        testRxjavaService?.getWeatherInfo()
            ?.subscribeOn(Schedulers.io())
            ?.observeOn(AndroidSchedulers.mainThread())
            ?.subscribe(observer)
    }
}